package cn.dglydrpy.study.j2ee.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.dglydrpy.study.j2ee.manage.dao.UserDAO;
/*
 * 删除用户数据后重定向到list
 */
public class DelUserServlet3 extends HttpServlet{
	
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf8");
		PrintWriter out = response.getWriter();
		
		UserDAO dao = new UserDAO();
		try{
			dao.deleteById(Integer.parseInt(request.getParameter("id").trim()));
			response.sendRedirect("listUser3");
		} catch(Exception e){
			e.printStackTrace();
			out.println("系统繁忙，请稍后再试");
		}
	
	}
}
